<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: Technoweenie::AttachmentFu::InstanceMethods</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">Technoweenie::AttachmentFu::InstanceMethods</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu_rb.html">
                vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000089">after_process_attachment</a>&nbsp;&nbsp;
      <a href="#M000086">attachment_attributes_valid?</a>&nbsp;&nbsp;
      <a href="#M000091">callback_with_args</a>&nbsp;&nbsp;
      <a href="#M000068">content_type=</a>&nbsp;&nbsp;
      <a href="#M000079">copy_to_temp_file</a>&nbsp;&nbsp;
      <a href="#M000067">create_or_update_thumbnail</a>&nbsp;&nbsp;
      <a href="#M000081">create_temp_file</a>&nbsp;&nbsp;
      <a href="#M000092">destroy_thumbnails</a>&nbsp;&nbsp;
      <a href="#M000069">filename=</a>&nbsp;&nbsp;
      <a href="#M000087">find_or_initialize_thumbnail</a>&nbsp;&nbsp;
      <a href="#M000063">image?</a>&nbsp;&nbsp;
      <a href="#M000070">image_size</a>&nbsp;&nbsp;
      <a href="#M000088">process_attachment</a>&nbsp;&nbsp;
      <a href="#M000083">random_tempfile_filename</a>&nbsp;&nbsp;
      <a href="#M000090">resize_image_or_thumbnail!</a>&nbsp;&nbsp;
      <a href="#M000084">sanitize_filename</a>&nbsp;&nbsp;
      <a href="#M000071">save_attachment?</a>&nbsp;&nbsp;
      <a href="#M000085">set_size_from_temp_path</a>&nbsp;&nbsp;
      <a href="#M000077">temp_data</a>&nbsp;&nbsp;
      <a href="#M000078">temp_data=</a>&nbsp;&nbsp;
      <a href="#M000074">temp_path</a>&nbsp;&nbsp;
      <a href="#M000076">temp_path=</a>&nbsp;&nbsp;
      <a href="#M000075">temp_paths</a>&nbsp;&nbsp;
      <a href="#M000065">thumbnail_class</a>&nbsp;&nbsp;
      <a href="#M000066">thumbnail_name_for</a>&nbsp;&nbsp;
      <a href="#M000064">thumbnailable?</a>&nbsp;&nbsp;
      <a href="#M000072">uploaded_data</a>&nbsp;&nbsp;
      <a href="#M000073">uploaded_data=</a>&nbsp;&nbsp;
      <a href="#M000082">with_image</a>&nbsp;&nbsp;
      <a href="#M000080">write_to_temp_file</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000068" class="method-detail">
        <a name="M000068"></a>

        <div class="method-heading">
          <a href="#M000068" class="method-signature">
          <span class="method-name">content_type=</span><span class="method-args">(new_type)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sets the content type.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000068-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000068-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 220</span>
220:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">content_type=</span>(<span class="ruby-identifier">new_type</span>)
221:         <span class="ruby-identifier">write_attribute</span> <span class="ruby-identifier">:content_type</span>, <span class="ruby-identifier">new_type</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span>
222:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000079" class="method-detail">
        <a name="M000079"></a>

        <div class="method-heading">
          <a href="#M000079" class="method-signature">
          <span class="method-name">copy_to_temp_file</span><span class="method-args">(file)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Copies the given file to a randomly named Tempfile.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000079-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000079-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 298</span>
298:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">copy_to_temp_file</span>(<span class="ruby-identifier">file</span>)
299:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">copy_to_temp_file</span> <span class="ruby-identifier">file</span>, <span class="ruby-identifier">random_tempfile_filename</span>
300:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000067" class="method-detail">
        <a name="M000067"></a>

        <div class="method-heading">
          <a href="#M000067" class="method-signature">
          <span class="method-name">create_or_update_thumbnail</span><span class="method-args">(temp_file, file_name_suffix, *size)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Creates or updates the thumbnail for the current attachment.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000067-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000067-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 205</span>
205:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_or_update_thumbnail</span>(<span class="ruby-identifier">temp_file</span>, <span class="ruby-identifier">file_name_suffix</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">size</span>)
206:         <span class="ruby-identifier">thumbnailable?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">raise</span>(<span class="ruby-constant">ThumbnailError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">&quot;Can't create a thumbnail if the content type is not an image or there is no parent_id column&quot;</span>))
207:         <span class="ruby-identifier">returning</span> <span class="ruby-identifier">find_or_initialize_thumbnail</span>(<span class="ruby-identifier">file_name_suffix</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">thumb</span><span class="ruby-operator">|</span>
208:           <span class="ruby-identifier">thumb</span>.<span class="ruby-identifier">attributes</span> = {
209:             <span class="ruby-identifier">:content_type</span>             =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">content_type</span>, 
210:             <span class="ruby-identifier">:filename</span>                 =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">thumbnail_name_for</span>(<span class="ruby-identifier">file_name_suffix</span>), 
211:             <span class="ruby-identifier">:temp_path</span>                =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">temp_file</span>,
212:             <span class="ruby-identifier">:thumbnail_resize_options</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">size</span>
213:           }
214:           <span class="ruby-identifier">callback_with_args</span> <span class="ruby-identifier">:before_thumbnail_saved</span>, <span class="ruby-identifier">thumb</span>
215:           <span class="ruby-identifier">thumb</span>.<span class="ruby-identifier">save!</span>
216:         <span class="ruby-keyword kw">end</span>
217:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000081" class="method-detail">
        <a name="M000081"></a>

        <div class="method-heading">
          <a href="#M000081" class="method-signature">
          <span class="method-name">create_temp_file</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Stub for creating a temp file from the attachment data. This should be
defined in the backend module.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000081-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000081-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 308</span>
308:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create_temp_file</span>() <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000069" class="method-detail">
        <a name="M000069"></a>

        <div class="method-heading">
          <a href="#M000069" class="method-signature">
          <span class="method-name">filename=</span><span class="method-args">(new_name)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Sanitizes a filename.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000069-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000069-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 225</span>
225:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">filename=</span>(<span class="ruby-identifier">new_name</span>)
226:         <span class="ruby-identifier">write_attribute</span> <span class="ruby-identifier">:filename</span>, <span class="ruby-identifier">sanitize_filename</span>(<span class="ruby-identifier">new_name</span>)
227:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000063" class="method-detail">
        <a name="M000063"></a>

        <div class="method-heading">
          <a href="#M000063" class="method-signature">
          <span class="method-name">image?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Checks whether the attachment&#8216;s content type is an image content type
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000063-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000063-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 180</span>
180:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">image?</span>
181:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">image?</span>(<span class="ruby-identifier">content_type</span>)
182:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000070" class="method-detail">
        <a name="M000070"></a>

        <div class="method-heading">
          <a href="#M000070" class="method-signature">
          <span class="method-name">image_size</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the width/height in a suitable format for the image_tag helper:
(100x100)
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000070-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000070-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 230</span>
230:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">image_size</span>
231:         [<span class="ruby-identifier">width</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">height</span>.<span class="ruby-identifier">to_s</span>] <span class="ruby-operator">*</span> <span class="ruby-value str">'x'</span>
232:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000071" class="method-detail">
        <a name="M000071"></a>

        <div class="method-heading">
          <a href="#M000071" class="method-signature">
          <span class="method-name">save_attachment?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns true if the attachment data will be written to the storage system
on the next save
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000071-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000071-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 235</span>
235:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">save_attachment?</span>
236:         <span class="ruby-constant">File</span>.<span class="ruby-identifier">file?</span>(<span class="ruby-identifier">temp_path</span>.<span class="ruby-identifier">to_s</span>)
237:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000077" class="method-detail">
        <a name="M000077"></a>

        <div class="method-heading">
          <a href="#M000077" class="method-signature">
          <span class="method-name">temp_data</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Gets the data from the latest temp file. This will read the file into
memory.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000077-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000077-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 288</span>
288:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">temp_data</span>
289:         <span class="ruby-identifier">save_attachment?</span> <span class="ruby-value">? </span><span class="ruby-constant">File</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">temp_path</span>) <span class="ruby-operator">:</span> <span class="ruby-keyword kw">nil</span>
290:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000078" class="method-detail">
        <a name="M000078"></a>

        <div class="method-heading">
          <a href="#M000078" class="method-signature">
          <span class="method-name">temp_data=</span><span class="method-args">(data)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Writes the given data to a Tempfile and adds it to the collection of temp
files.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000078-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000078-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 293</span>
293:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">temp_data=</span>(<span class="ruby-identifier">data</span>)
294:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">temp_path</span> = <span class="ruby-identifier">write_to_temp_file</span> <span class="ruby-identifier">data</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">nil?</span>
295:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000074" class="method-detail">
        <a name="M000074"></a>

        <div class="method-heading">
          <a href="#M000074" class="method-signature">
          <span class="method-name">temp_path</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Gets the latest temp path from the collection of temp paths. While working
with an attachment, multiple Tempfile objects may be created for various
processing purposes (resizing, for example). An array of all the tempfile
objects is stored so that the Tempfile instance is held on to until
it&#8216;s not needed anymore. The collection is cleared after saving the
attachment.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000074-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000074-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 269</span>
269:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">temp_path</span>
270:         <span class="ruby-identifier">p</span> = <span class="ruby-identifier">temp_paths</span>.<span class="ruby-identifier">first</span>
271:         <span class="ruby-identifier">p</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:path</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">path</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">to_s</span>
272:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000076" class="method-detail">
        <a name="M000076"></a>

        <div class="method-heading">
          <a href="#M000076" class="method-signature">
          <span class="method-name">temp_path=</span><span class="method-args">(value)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Adds a new <a href="InstanceMethods.html#M000074">temp_path</a> to the
array. This should take a string or a Tempfile. This class makes no attempt
to remove the files, so Tempfiles should be used. Tempfiles remove
themselves when they go out of scope. You can also use string paths for
temporary files, such as those used for uploaded files in a web server.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000076-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000076-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 282</span>
282:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">temp_path=</span>(<span class="ruby-identifier">value</span>)
283:         <span class="ruby-identifier">temp_paths</span>.<span class="ruby-identifier">unshift</span> <span class="ruby-identifier">value</span>
284:         <span class="ruby-identifier">temp_path</span>
285:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000075" class="method-detail">
        <a name="M000075"></a>

        <div class="method-heading">
          <a href="#M000075" class="method-signature">
          <span class="method-name">temp_paths</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Gets an array of the currently used temp paths. Defaults to a copy of
full_filename.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000075-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000075-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 275</span>
275:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">temp_paths</span>
276:         <span class="ruby-ivar">@temp_paths</span> <span class="ruby-operator">||=</span> (<span class="ruby-identifier">new_record?</span> <span class="ruby-operator">||</span> <span class="ruby-operator">!</span><span class="ruby-constant">File</span>.<span class="ruby-identifier">exist?</span>(<span class="ruby-identifier">full_filename</span>)) <span class="ruby-operator">?</span> [] <span class="ruby-operator">:</span> [<span class="ruby-identifier">copy_to_temp_file</span>(<span class="ruby-identifier">full_filename</span>)]
277:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000065" class="method-detail">
        <a name="M000065"></a>

        <div class="method-heading">
          <a href="#M000065" class="method-signature">
          <span class="method-name">thumbnail_class</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns the class used to create new thumbnails for this attachment.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000065-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000065-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 190</span>
190:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">thumbnail_class</span>
191:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">thumbnail_class</span>
192:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000066" class="method-detail">
        <a name="M000066"></a>

        <div class="method-heading">
          <a href="#M000066" class="method-signature">
          <span class="method-name">thumbnail_name_for</span><span class="method-args">(thumbnail = nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Gets the thumbnail name for a filename. &#8216;foo.jpg&#8217; becomes
&#8216;foo_thumbnail.jpg&#8216;
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000066-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000066-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 195</span>
195:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">thumbnail_name_for</span>(<span class="ruby-identifier">thumbnail</span> = <span class="ruby-keyword kw">nil</span>)
196:         <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">filename</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">thumbnail</span>.<span class="ruby-identifier">blank?</span>
197:         <span class="ruby-identifier">ext</span> = <span class="ruby-keyword kw">nil</span>
198:         <span class="ruby-identifier">basename</span> = <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">gsub</span> <span class="ruby-regexp re">/\.\w+$/</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span>
199:           <span class="ruby-identifier">ext</span> = <span class="ruby-identifier">s</span>; <span class="ruby-value str">''</span>
200:         <span class="ruby-keyword kw">end</span>
201:         <span class="ruby-node">&quot;#{basename}_#{thumbnail}#{ext}&quot;</span>
202:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000064" class="method-detail">
        <a name="M000064"></a>

        <div class="method-heading">
          <a href="#M000064" class="method-signature">
          <span class="method-name">thumbnailable?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Returns true/false if an attachment is thumbnailable. A thumbnailable
attachment has an image content type and the parent_id attribute.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000064-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000064-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 185</span>
185:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">thumbnailable?</span>
186:         <span class="ruby-identifier">image?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:parent_id</span>)
187:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000072" class="method-detail">
        <a name="M000072"></a>

        <div class="method-heading">
          <a href="#M000072" class="method-signature">
          <span class="method-name">uploaded_data</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
nil placeholder in case this field is used in a form.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000072-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000072-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 240</span>
240:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uploaded_data</span>() <span class="ruby-keyword kw">nil</span>; <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000073" class="method-detail">
        <a name="M000073"></a>

        <div class="method-heading">
          <a href="#M000073" class="method-signature">
          <span class="method-name">uploaded_data=</span><span class="method-args">(file_data)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
This method handles the uploaded file object. If you set the field name to
<a href="InstanceMethods.html#M000072">uploaded_data</a>, you don&#8216;t
need any special code in your controller.
</p>
<pre>
  &lt;% form_for :attachment, :html =&gt; { :multipart =&gt; true } do |f| -%&gt;
    &lt;p&gt;&lt;%= f.file_field :uploaded_data %&gt;&lt;/p&gt;
    &lt;p&gt;&lt;%= submit_tag :Save %&gt;
  &lt;% end -%&gt;

  @attachment = Attachment.create! params[:attachment]
</pre>
<p>
TODO: Allow it to work with Merb tempfiles too.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000073-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000073-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 253</span>
253:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">uploaded_data=</span>(<span class="ruby-identifier">file_data</span>)
254:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">file_data</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">file_data</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> 
255:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">content_type</span> = <span class="ruby-identifier">file_data</span>.<span class="ruby-identifier">content_type</span>
256:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">filename</span>     = <span class="ruby-identifier">file_data</span>.<span class="ruby-identifier">original_filename</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:filename</span>)
257:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">file_data</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">StringIO</span>)
258:           <span class="ruby-identifier">file_data</span>.<span class="ruby-identifier">rewind</span>
259:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">temp_data</span> = <span class="ruby-identifier">file_data</span>.<span class="ruby-identifier">read</span>
260:         <span class="ruby-keyword kw">else</span>
261:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">temp_path</span> = <span class="ruby-identifier">file_data</span>.<span class="ruby-identifier">path</span>
262:         <span class="ruby-keyword kw">end</span>
263:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000082" class="method-detail">
        <a name="M000082"></a>

        <div class="method-heading">
          <a href="#M000082" class="method-signature">
          <span class="method-name">with_image</span><span class="method-args">(&amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Allows you to work with a processed representation (RMagick, ImageScience,
etc) of the attachment in a block.
</p>
<pre>
  @attachment.with_image do |img|
    self.data = img.thumbnail(100, 100).to_blob
  end
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000082-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000082-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 316</span>
316:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">with_image</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
317:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">with_image</span>(<span class="ruby-identifier">temp_path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
318:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000080" class="method-detail">
        <a name="M000080"></a>

        <div class="method-heading">
          <a href="#M000080" class="method-signature">
          <span class="method-name">write_to_temp_file</span><span class="method-args">(data)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Writes the given file to a randomly named Tempfile.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000080-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000080-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 303</span>
303:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">write_to_temp_file</span>(<span class="ruby-identifier">data</span>)
304:         <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">write_to_temp_file</span> <span class="ruby-identifier">data</span>, <span class="ruby-identifier">random_tempfile_filename</span>
305:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Protected Instance methods</h3>

      <div id="method-M000089" class="method-detail">
        <a name="M000089"></a>

        <div class="method-heading">
          <a href="#M000089" class="method-signature">
          <span class="method-name">after_process_attachment</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Cleans up after processing. Thumbnails are created, the attachment is
stored to the backend, and the <a
href="InstanceMethods.html#M000075">temp_paths</a> are cleared.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000089-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000089-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 363</span>
363:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">after_process_attachment</span>
364:           <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@saved_attachment</span>
365:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:process_attachment_with_processing</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">thumbnailable?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">attachment_options</span>[<span class="ruby-identifier">:thumbnails</span>].<span class="ruby-identifier">blank?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">parent_id</span>.<span class="ruby-identifier">nil?</span>
366:               <span class="ruby-identifier">temp_file</span> = <span class="ruby-identifier">temp_path</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">create_temp_file</span>
367:               <span class="ruby-identifier">attachment_options</span>[<span class="ruby-identifier">:thumbnails</span>].<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">suffix</span>, <span class="ruby-identifier">size</span><span class="ruby-operator">|</span> <span class="ruby-identifier">create_or_update_thumbnail</span>(<span class="ruby-identifier">temp_file</span>, <span class="ruby-identifier">suffix</span>, <span class="ruby-operator">*</span><span class="ruby-identifier">size</span>) }
368:             <span class="ruby-keyword kw">end</span>
369:             <span class="ruby-identifier">save_to_storage</span>
370:             <span class="ruby-ivar">@temp_paths</span>.<span class="ruby-identifier">clear</span>
371:             <span class="ruby-ivar">@saved_attachment</span> = <span class="ruby-keyword kw">nil</span>
372:             <span class="ruby-identifier">callback</span> <span class="ruby-identifier">:after_attachment_saved</span>
373:           <span class="ruby-keyword kw">end</span>
374:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000086" class="method-detail">
        <a name="M000086"></a>

        <div class="method-heading">
          <a href="#M000086" class="method-signature">
          <span class="method-name">attachment_attributes_valid?</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
validates the size and content_type attributes according to the current
model&#8216;s options
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000086-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000086-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 343</span>
343:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">attachment_attributes_valid?</span>
344:           [<span class="ruby-identifier">:size</span>, <span class="ruby-identifier">:content_type</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">attr_name</span><span class="ruby-operator">|</span>
345:             <span class="ruby-identifier">enum</span> = <span class="ruby-identifier">attachment_options</span>[<span class="ruby-identifier">attr_name</span>]
346:             <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">add</span> <span class="ruby-identifier">attr_name</span>, <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Errors</span>.<span class="ruby-identifier">default_error_messages</span>[<span class="ruby-identifier">:inclusion</span>] <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">enum</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">enum</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">send</span>(<span class="ruby-identifier">attr_name</span>))
347:           <span class="ruby-keyword kw">end</span>
348:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000091" class="method-detail">
        <a name="M000091"></a>

        <div class="method-heading">
          <a href="#M000091" class="method-signature">
          <span class="method-name">callback_with_args</span><span class="method-args">(method, arg = self)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Yanked from ActiveRecord::Callbacks, modified so I can pass args to the
callbacks besides self. Only accept blocks, however
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000091-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000091-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 387</span>
387:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">callback_with_args</span>(<span class="ruby-identifier">method</span>, <span class="ruby-identifier">arg</span> = <span class="ruby-keyword kw">self</span>)
388:           <span class="ruby-identifier">notify</span>(<span class="ruby-identifier">method</span>)
389: 
390:           <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">nil</span>
391:           <span class="ruby-identifier">callbacks_for</span>(<span class="ruby-identifier">method</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">callback</span><span class="ruby-operator">|</span>
392:             <span class="ruby-identifier">result</span> = <span class="ruby-identifier">callback</span>.<span class="ruby-identifier">call</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">arg</span>)
393:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">result</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">false</span>
394:           <span class="ruby-keyword kw">end</span>
395: 
396:           <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
397:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000092" class="method-detail">
        <a name="M000092"></a>

        <div class="method-heading">
          <a href="#M000092" class="method-signature">
          <span class="method-name">destroy_thumbnails</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Removes the thumbnails for the attachment, if it has any
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000092-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000092-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 400</span>
400:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">destroy_thumbnails</span>
401:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">thumbnails</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">thumbnail</span><span class="ruby-operator">|</span> <span class="ruby-identifier">thumbnail</span>.<span class="ruby-identifier">destroy</span> } <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">thumbnailable?</span>
402:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000087" class="method-detail">
        <a name="M000087"></a>

        <div class="method-heading">
          <a href="#M000087" class="method-signature">
          <span class="method-name">find_or_initialize_thumbnail</span><span class="method-args">(file_name_suffix)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Initializes a new thumbnail with the given suffix.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000087-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000087-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 351</span>
351:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">find_or_initialize_thumbnail</span>(<span class="ruby-identifier">file_name_suffix</span>)
352:           <span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:parent_id</span>) <span class="ruby-operator">?</span>
353:             <span class="ruby-identifier">thumbnail_class</span>.<span class="ruby-identifier">find_or_initialize_by_thumbnail_and_parent_id</span>(<span class="ruby-identifier">file_name_suffix</span>.<span class="ruby-identifier">to_s</span>, <span class="ruby-identifier">id</span>) <span class="ruby-operator">:</span>
354:             <span class="ruby-identifier">thumbnail_class</span>.<span class="ruby-identifier">find_or_initialize_by_thumbnail</span>(<span class="ruby-identifier">file_name_suffix</span>.<span class="ruby-identifier">to_s</span>)
355:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000088" class="method-detail">
        <a name="M000088"></a>

        <div class="method-heading">
          <a href="#M000088" class="method-signature">
          <span class="method-name">process_attachment</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Stub for a <a href="InstanceMethods.html#M000088">process_attachment</a>
method in a processor
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000088-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000088-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 358</span>
358:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_attachment</span>
359:           <span class="ruby-ivar">@saved_attachment</span> = <span class="ruby-identifier">save_attachment?</span>
360:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000083" class="method-detail">
        <a name="M000083"></a>

        <div class="method-heading">
          <a href="#M000083" class="method-signature">
          <span class="method-name">random_tempfile_filename</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Generates a unique filename for a Tempfile.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000083-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000083-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 322</span>
322:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">random_tempfile_filename</span>
323:           <span class="ruby-node">&quot;#{rand Time.now.to_i}#{filename || 'attachment'}&quot;</span>
324:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000090" class="method-detail">
        <a name="M000090"></a>

        <div class="method-heading">
          <a href="#M000090" class="method-signature">
          <span class="method-name">resize_image_or_thumbnail!</span><span class="method-args">(img)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Resizes the given processed img object with either the attachment resize
options or the thumbnail resize options.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000090-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000090-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 377</span>
377:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resize_image_or_thumbnail!</span>(<span class="ruby-identifier">img</span>)
378:           <span class="ruby-keyword kw">if</span> (<span class="ruby-operator">!</span><span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">:parent_id</span>) <span class="ruby-operator">||</span> <span class="ruby-identifier">parent_id</span>.<span class="ruby-identifier">nil?</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">attachment_options</span>[<span class="ruby-identifier">:resize_to</span>] <span class="ruby-comment cmt"># parent image</span>
379:             <span class="ruby-identifier">resize_image</span>(<span class="ruby-identifier">img</span>, <span class="ruby-identifier">attachment_options</span>[<span class="ruby-identifier">:resize_to</span>])
380:           <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">thumbnail_resize_options</span> <span class="ruby-comment cmt"># thumbnail</span>
381:             <span class="ruby-identifier">resize_image</span>(<span class="ruby-identifier">img</span>, <span class="ruby-identifier">thumbnail_resize_options</span>) 
382:           <span class="ruby-keyword kw">end</span>
383:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000084" class="method-detail">
        <a name="M000084"></a>

        <div class="method-heading">
          <a href="#M000084" class="method-signature">
          <span class="method-name">sanitize_filename</span><span class="method-args">(filename)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000084-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000084-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 326</span>
326:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sanitize_filename</span>(<span class="ruby-identifier">filename</span>)
327:           <span class="ruby-identifier">returning</span> <span class="ruby-identifier">filename</span>.<span class="ruby-identifier">strip</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">name</span><span class="ruby-operator">|</span>
328:             <span class="ruby-comment cmt"># NOTE: File.basename doesn't work right with Windows paths on Unix</span>
329:             <span class="ruby-comment cmt"># get only the filename, not the whole path</span>
330:             <span class="ruby-identifier">name</span>.<span class="ruby-identifier">gsub!</span> <span class="ruby-regexp re">/^.*(\\|\/)/</span>, <span class="ruby-value str">''</span>
331:             
332:             <span class="ruby-comment cmt"># Finally, replace all non alphanumeric, underscore or periods with underscore</span>
333:             <span class="ruby-identifier">name</span>.<span class="ruby-identifier">gsub!</span> <span class="ruby-regexp re">/[^\w\.\-]/</span>, <span class="ruby-value str">'_'</span>
334:           <span class="ruby-keyword kw">end</span>
335:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000085" class="method-detail">
        <a name="M000085"></a>

        <div class="method-heading">
          <a href="#M000085" class="method-signature">
          <span class="method-name">set_size_from_temp_path</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
before_validation callback.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000085-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000085-source">
<pre>
     <span class="ruby-comment cmt"># File vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb, line 338</span>
338:         <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_size_from_temp_path</span>
339:           <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">size</span> = <span class="ruby-constant">File</span>.<span class="ruby-identifier">size</span>(<span class="ruby-identifier">temp_path</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">save_attachment?</span>
340:         <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>